//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for Support
public struct SupportErrorType: AWSErrorType {
    enum Code: String {
        case attachmentIdNotFound = "AttachmentIdNotFound"
        case attachmentLimitExceeded = "AttachmentLimitExceeded"
        case attachmentSetExpired = "AttachmentSetExpired"
        case attachmentSetIdNotFound = "AttachmentSetIdNotFound"
        case attachmentSetSizeLimitExceeded = "AttachmentSetSizeLimitExceeded"
        case caseCreationLimitExceeded = "CaseCreationLimitExceeded"
        case caseIdNotFound = "CaseIdNotFound"
        case describeAttachmentLimitExceeded = "DescribeAttachmentLimitExceeded"
        case internalServerError = "InternalServerError"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize Support
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// An attachment with the specified ID could not be found.
    public static var attachmentIdNotFound: Self { .init(.attachmentIdNotFound) }
    /// The limit for the number of attachment sets created in a short period of time has been exceeded.
    public static var attachmentLimitExceeded: Self { .init(.attachmentLimitExceeded) }
    /// The expiration time of the attachment set has passed. The set expires 1 hour after it is created.
    public static var attachmentSetExpired: Self { .init(.attachmentSetExpired) }
    /// An attachment set with the specified ID could not be found.
    public static var attachmentSetIdNotFound: Self { .init(.attachmentSetIdNotFound) }
    /// A limit for the size of an attachment set has been exceeded. The limits are three attachments and 5 MB per attachment.
    public static var attachmentSetSizeLimitExceeded: Self { .init(.attachmentSetSizeLimitExceeded) }
    /// The case creation limit for the account has been exceeded.
    public static var caseCreationLimitExceeded: Self { .init(.caseCreationLimitExceeded) }
    /// The requested caseId could not be located.
    public static var caseIdNotFound: Self { .init(.caseIdNotFound) }
    /// The limit for the number of DescribeAttachment requests in a short period of time has been exceeded.
    public static var describeAttachmentLimitExceeded: Self { .init(.describeAttachmentLimitExceeded) }
    /// An internal server error occurred.
    public static var internalServerError: Self { .init(.internalServerError) }
}

extension SupportErrorType: Equatable {
    public static func == (lhs: SupportErrorType, rhs: SupportErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension SupportErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
